import { createRouter, createWebHashHistory } from 'vue-router'
// 1. 定义路由组件.
// 也可以从其他文件导入
import Layout from '@/layout/index.vue'
// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。
export const sidebarRoutes = [
    {
        path: "home",
        component: () => import('@/views/home/index.vue'),
        name: 'home',
        meta: {
            title: 'home',
            icon: 'House'
        }
    },
    {
        path: "other",
        component: () => import('@/views/other/index.vue'),
        name: 'other',
        meta: {
            title: 'other',
            icon: 'Plus'
        },
        children: [
            {
                path: "linechart",
                component: () => import('@/views/other/other1.vue'),
                name: 'other1',
                meta: {
                    title: 'other1',
                    // icon: ''
                },
            },
            {
                path: "other2",
                component: () => import('@/views/other/other2.vue'),
                name: 'other2',
                meta: {
                    title: 'other2',
                    // icon: ''
                },
            }
        ]
    },
    {
        path: "charts",
        component: () => import('@/views/charts/index.vue'),
        name: 'charts',
        meta: {
            title: 'charts',
            icon: 'Plus'
        },
        children: [
            {
                path: "linechart",
                component: () => import('@/views/charts/linechart/index.vue'),
                name: 'linechart',
                meta: {
                    title: 'linechart',
                    // icon: ''
                },
            },
            {
                path: "test",
                component: () => import('@/views/charts/test/index.vue'),
                name: 'test',
                meta: {
                    title: 'test',
                    // icon: ''
                },
            },
        ]
    }
]
export const routes = [
    {
        path: '/login',
        component: ()=>import('@/views/login/index.vue'),
        name: "login",
        meta:{
            hidden:true
        }
    },
    {
        path: '/',
        component: Layout,
        name: "layout",
        redirect: '/home',
        meta:{
            hidden:true
        },
        children: sidebarRoutes
    },
    //   { path: '/about', component: About },
]

// 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
})
export default router
